package com.haibara.codesubmiteval.chain.redisRunnerChain;

import com.haibara.codesubmiteval.constant.RedisKeyConstant;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * 系统总题目数
 *
 * @Author: mengyu
 * @Date: 2025/4/29
 */
@Order(4)
@Component
@Slf4j
public class QuestionNumberInitHandler extends RedisInitHandler {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void handleRedisInit(RedisInitContext context) {
        stringRedisTemplate.opsForValue().set(
                RedisKeyConstant.questionNumber,
                String.valueOf(context.getQuestionNumber())
        );
        log.info("RedisInit - QuestionNumber完成");
        if (next != null) next.handleRedisInit(context);
    }
}
